import request from "@/utils/request";
import type {
  ITrademarkList,
  GetBaseTrademark,
  ITrademark,
} from "./model/trademark";

enum Api {
  getTrademarkListApi = `/admin/product/baseTrademark`,
  getSaveTrademarkApi = `/admin/product/baseTrademark/save`,
  getDeleTrademarkApi = `/admin/product/baseTrademark/remove`,
  getPutTrademarkApi = `/admin/product/baseTrademark/update`,
}
// 获取总数据
export const getAllTrademark = () => {
  return request.get<any, ITrademarkList>(
    `/admin/product/baseTrademark/getTrademarkList`
  );
};
// 获取分页列表
export const getBaseTrademark = (page: number, limit: number) => {
  return request.get<any, GetBaseTrademark>(
    // 这个是在path中发  要一个params或者query参数
    `${Api.getTrademarkListApi}/${page}/${limit}`
  );
};

/**
 * 获取新增接口
 * @param logoUrl 品牌名称
 * @param tmName 品牌LOGO
 * @returns null
 */
export const getSaveTrademark = (tmName: string, logoUrl: string) => {
  return request.post<any, null>(Api.getSaveTrademarkApi, {
    // 这是在请求体中发
    logoUrl,
    tmName,
  });
};

/**
 * 获取删除接口
 * @param id id名称
 * @returns null
 */
export const getDeleteTrademark = (id: number) => {
  return request.delete<any, null>(`${Api.getDeleTrademarkApi}/${id}`);
};

export const getPutTrademark = (tm: ITrademark) => {
  return request.put<any, null>(`${Api.getPutTrademarkApi}`, tm);
};
